package com.ethan.common.orm.model;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import org.hibernate.annotations.GenericGenerator;

/**
 * 统一定义id的实体基类.
 * 
 * 基类统一定义id的属性名称、数据类型、列名映射及生成策略.
 * 子类可重载getId()函数重定义id的列名映射和生成策略.
 * 
 * @author liangjw
 * @version 1.0
 */
//JPA 基类的标识
@MappedSuperclass
public abstract class IDModel{
	protected Long id;
	
	@Id
	//@GeneratedValue(strategy = IDENTITY)
	@GeneratedValue
	//@SequenceGenerator(name = "generator_id_user",sequenceName = "seq_name_user",allocationSize=1)
	@GenericGenerator(name = "idGenerator", strategy = "native")   
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
}
